{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "94295ef8-afa1-4a5e-bf66-bcb1cf78cc73",
   "metadata": {},
   "source": [
    "Chapter 05\n",
    "# 字符串和元组拆包、打包\n",
    "Book_1《编程不难》 | 鸢尾花书：从加减乘除到机器学习  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6bbc1ca2-845a-41ef-946d-0ab278346d71",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['b', 'c']\n"
     ]
    }
   ],
   "source": [
    "# 定义字符串\n",
    "string_0 = 'abcd'\n",
    "first, *str_rest, last = string_0\n",
    "print(str_rest) # ['b', 'c']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7c5882ee-ca13-4209-9c43-2ba7fb1ac322",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2, 3]\n"
     ]
    }
   ],
   "source": [
    "# 定义元组\n",
    "tuple_0 = (1,2,3,4)\n",
    "first, *tuple_rest, last = tuple_0\n",
    "print(tuple_rest) # [2, 3]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
